
#ifndef					__SPEAKER_H_
# define				__SPEAKER_H_

# include				<string>
# include				<cstdlib>
# include				<queue>
# include				<qmutex.h>
# include				"portaudio.h"
# include				"RotatingBuffer.h"
# include				"ISpeaker.h"
# include				"ssample.h"

class					Speaker : public ISpeaker
{
public:
	Speaker();
	~Speaker();

public:
	int					playCall(short *);
	void				start();
	void				stop();
	void				init();
	void				write(ISoundPacket*, unsigned int);
	PaStream			*_stream;
	QMutex				_mutex;
	
private:
	std::queue<ssample*>	_buffer;
	PaStreamParameters  _outputParameters;
	ISoundPacket		*_packet;
	size_t				_sample_rate;
	size_t				_frames_per_buffer;
	size_t				_num_channels;
	int					_status;
};

#endif // !__SPEAKER_H__